package ooday03;

//引用类型数组的演示
public class RefArrayDemo {
    public static void main(String[] args) {


        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑", 5, "白");
        dogs[1] = new Dog("小白", 5, "黑");
        dogs[2] = new Dog("小灰", 3, "灰");
//        System.out.println(dogs[0].eat());
        System.out.println(dogs[0].name);
        dogs[1].age = 4;
        dogs[1].swim();
        for (int i = 0;i< dogs.length;i++){
            System.out.println(dogs[i].color);
            System.out.println(dogs[i].age);
            System.out.println(dogs[i].name);
        }

        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小花", 5, "花");
        chicks[1] = new Chick("大花", 2, "白");
        for (int i = 0;i< chicks.length;i++){
            System.out.println(chicks[i].color);
            System.out.println(chicks[i].age);
            System.out.println(chicks[i].name);
        }
        Fish[] fish = new Fish[4];
        fish[0] = new Fish("大金", 2, "金");
        fish[1] = new Fish("小金", 2, "也是金");
        fish[2] = new Fish("小小金", 1, "还是金");
        fish[3] = new Fish("小小小金", 0, "有是金");
        for (int i = 0;i< fish.length;i++){
            System.out.println(fish[i].color);
            System.out.println(fish[i].age);
            System.out.println(fish[i].name);
        }












        /*

         Dog[] dogs = new Dog[3];
        //声明Chick型数组chicks,包含三个元素,每个元素都是chick类型,默认值为null
        Chick[] chicks = new Chick[3];
        //声明Fish型数组fish,包含两个元素,每个元素都是Fish类型,默认为null
        Fish[] fish = new Fish[2];

        */

    }
}
